package distrcomp;

import java.io.Serializable;

/*
 * Shipment class
 */

public class Shipment implements Serializable {
	private static final long serialVersionUID = 1L;
	private Address source = null;
	private Address destination = null;
	private ShippingType shippingType = ShippingType.GROUND;
	private ShippingState shippingState = ShippingState.PENDING;
	private Product product = null;
	private float price = 0;
	private int ID;
	
	public Shipment(Address source, Address destination, ShippingType shippingType, Product product, float price, int ID) {
		this.source = source;
		this.destination = destination;
		this.shippingType = shippingType;
		this.product = product;
		this.price = price;
		this.ID = ID;
	}
	
	public void print() {
		System.out.println("----------------");
		System.out.println("Shipment details");
		System.out.println("----------------");
		System.out.println();
		System.out.print("Source address: ");
		this.source.print();
		System.out.print("Destination address: ");
		this.destination.print();
		System.out.print("Shipping type: ");
		switch(this.shippingType) {
			case GROUND:
				System.out.println("ground");
				break;
			case AIR:
				System.out.println(" air");
				break;
			case AIR_PRIORITY:
				System.out.println(" air (priority)");
				break;
			default:
				break;				
		}
		System.out.println("Shipping cost: " + price + " " + product.getCur());
		System.out.println("ID: " + ID);
		System.out.print("Shipping state: ");
		switch(this.shippingState) {
			case PENDING:
				System.out.println("pending");
				break;
			case IN_ROUTE:
				System.out.println(" in route");
				break;
			case ARRIVED:
				System.out.println(" arrived");
				break;
			default:
				break;				
		}
		System.out.println();
		System.out.println("Product details:");
		System.out.println();
		this.product.print();
	}

	public Address getSource() {
		return source;
	}

	public void setSource(Address source) {
		this.source = source;
	}

	public Address getDestination() {
		return destination;
	}

	public void setDestination(Address destination) {
		this.destination = destination;
	}

	public ShippingType getShippingType() {
		return shippingType;
	}

	public void setShippingType(ShippingType shippingType) {
		this.shippingType = shippingType;
	}
	
	public ShippingState getShippingState() {
		return shippingState;
	}

	public void setShippingState(ShippingState shippingState) {
		this.shippingState = shippingState;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
	
	public int getID() {
		return ID;
	}
}
